import { defineStore } from 'pinia'
import { ref, reactive } from 'vue'

export const useConfigStore = defineStore('config', () => {
  const apiConfig = reactive({
    baseUrl: 'https://api.xiaocai.com',
    token: '',
    timeout: 30
  })

  const storageConfig = reactive({
    autoSync: true,
    maxLocalItems: 1000,
    retentionDays: 30
  })

  const advancedConfig = reactive({
    debugMode: false,
    enableNotification: true
  })

  const updateApiConfig = (config) => {
    Object.assign(apiConfig, config)
  }

  const updateStorageConfig = (config) => {
    Object.assign(storageConfig, config)
  }

  const updateAdvancedConfig = (config) => {
    Object.assign(advancedConfig, config)
  }

  return {
    apiConfig,
    storageConfig,
    advancedConfig,
    updateApiConfig,
    updateStorageConfig,
    updateAdvancedConfig
  }
})